﻿@model planerka.DataAccess.ViewModels.pageAndPageCategoriesViewModel
@using planerka.Web.Helpers;
@{ ViewBag.Title = "Управление категориями страниц";}


@section HeadContent 
{
    <link href="@Url.Content("~/Content/jquery.treeview.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery.treeview.js")" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("#browser").treeview();
        })
    </script>
}

    <h2>Управление категориями страниц</h2>

    @Html.ActionLink("Top level", "managePageCategories", new { id = 0 })
    <br /><br />
    @using (Html.BeginForm())
    {
    <div id="divWrapper" style="min-height: 500px;">
    <div style="float:left; width: 250px;">


    @{ 
        int selected_ID = 0;
        int parent_ID = 0;
        if (Model.selectedPageCategory != null)
        {
            selected_ID = Model.selectedPageCategory.ID;
            if (Model.selectedPageCategory.parent_ID != null)
            { parent_ID = (int)Model.selectedPageCategory.parent_ID; }
        }
        @Html.Raw(Html.renderPageCategories(selected_ID)); }
    </div>
    <div style="margin-left: 250px;">
    <!-- Элементы управления -->
    
        @Html.HiddenFor(m => m.selectedPageCategory.ID)
        
        <div class="editor-label">
            
            <table class="renderTable" style="width: 450px; border: 0px !important;" cellpadding="0" cellspacing="0">
            <tr>
                <td style="border: 0px; width: 300px; padding: 0px;">
                    <div class="editor-label">
                        @Html.LabelFor(m => m.selectedPageCategory.name)
                    </div>
                </td>
                <td style="border: 0px; width: 150px; padding: 0px;">
                        <!-- do not change buttons values! -->
                        <input type="submit" value="Up" name="confirmButton" class="buttonsUpDown" />
                        <input type="submit" value="Down" name="confirmButton" class="buttonsUpDown" />
                    
                </td>
            </tr>
        </table>
        </div>
         <div class="editor-field">
            @Html.TextBoxFor(m => m.selectedPageCategory.name, new { style = "width: 450px;" })
            @Html.ValidationMessageFor(m => m.selectedPageCategory.name)
         </div>

         <div class="editor-label">
            Родительская категория
        </div>
         <div class="editor-field">
            @(Html.DropDownListFor(m => m.selectedPageCategory.parent_ID,
             new SelectList(ViewData["pageCategories"] as System.Collections.IEnumerable, "id",
                 "pageCategoryRouteValue", parent_ID.ToString()), new { style = "width: 450px;" }))
         </div>
         

         <div class="editor-label">
            @Html.LabelFor(m => m.selectedPageCategory.tag)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(m => m.selectedPageCategory.tag, new { style = "width: 450px;" })
            @Html.ValidationMessageFor(m => m.selectedPageCategory.tag)
         </div>
         
         <br />
        <input type="submit" value="Сохранить" name="confirmButton" />
        <input type="submit" value="Добавить новую категорию" name="confirmButton" />
        <input type="submit" value="Удалить" name="confirmButton"  onclick="return confirm('Вы действительно хотите удалить категорию?');" />
        <br />
        
        <span class="resultMessage">@Html.Raw(ViewData["resultMessage"] != null ? ("<span>" + ViewData["resultMessage"] + "</span>") : "")</span> 

        
    </div>
    </div>
     } 
    <div class="clear">&nbsp;</div>


